package com.hyx.api.controller.applet_recover;

import com.hyx.api.config.ApiPrefixRestController;
import com.hyx.api.domain.bo.RecycleReceivingAddrBo;
import com.hyx.api.service.IAppCommonService;
import com.hyx.api.service.IAppRecoverService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.Date;

@RequiredArgsConstructor
@ApiPrefixRestController
@RequestMapping("/appRecoverApi/owner")
public class RecoveOwnerController extends BaseController {

    @Autowired
    private IAppCommonService appCommonService;
    @Autowired
    private IAppRecoverService appRecoverService;

    /**
     * 获取货物跟踪信息
     *
     * @return
     */
    @GetMapping("/queryRecycleGoodsTrack")
    public AjaxResult queryRecycleGoodsTrack() {
        return appRecoverService.queryRecycleGoodsTrack();
    }

    /**
     * 获取货物跟踪相关列表
     *
     * @param queType 1：待发货
     *                2：超时
     * @return
     */
    @GetMapping("/queryGoodsTrackList")
    public TableDataInfo queryGoodsTrackList(@RequestParam("queType") Integer queType) {
        startPage();
        return getDataTable(appCommonService.queryGoodsTrackList(queType));
    }

    /**
     * 创建/更新回收商收货地址
     *
     * @param bo
     * @return
     */
    @PostMapping("/createOrUpdateRecycleRecAddr")
    public AjaxResult createOrUpdateRecycleRecAddr(@RequestBody @Valid RecycleReceivingAddrBo bo) {
        return appRecoverService.createOrUpdateRecycleRecAddr(bo);
    }

    /**
     * 删除回收商收货地址
     *
     * @param id
     * @return
     */
    @PostMapping("/delRecycleRecAddr")
    public AjaxResult delRecycleRecAddr(@RequestParam Integer id) {
        return appRecoverService.delRecycleRecAddr(id);
    }

    /**
     * 获取回收商收货地址列表
     *
     * @param keyword
     * @return
     */
    @GetMapping("/queryRecycleRecAddrList")
    public AjaxResult queryRecycleRecAddrList(String keyword) {
        return appRecoverService.queryRecycleRecAddrList(keyword);
    }

    /**
     * 回收商绑定合作商户
     *
     * @param companyId
     * @return
     */
    @GetMapping("/bindCompany")
    public AjaxResult bindCompany(@RequestParam Integer companyId) {
        return appRecoverService.bindCompany(companyId);
    }

    /**
     * 删除回收商绑定的商户关系
     *
     * @param id
     * @return
     */
    @GetMapping("/delBindCompany")
    public AjaxResult delBindCompany(@RequestParam Integer id) {
        return appRecoverService.delBindCompany(id);
    }

    /**
     * 获取回收商绑定的商户列表
     *
     * @param companyName
     * @return
     */
    @GetMapping("/queryBindCompanyList")
    public AjaxResult queryBindCompanyList(@RequestParam String companyName) {
        return appRecoverService.queryBindCompanyList(companyName);
    }

}
